require "ImguiWin/BaseImguiWindow"
require "UnityEngine.SystemInfo"

local P = NewClass(BaseImguiWindow, ClassFromFile(...));

local GUILayout = UnityEngine.GUILayout
local GUI = UnityEngine.GUI
local Screen = UnityEngine.Screen



local scrollPos = Vector2.zero

function P:OnGUI()
	GUIFun.Init()
	GUILayout.Box("", GUILayout.Height(Screen.height), GUILayout.Width(Screen.width))
	self:Show()
end

function P:Show()
	if not self.unfoldInfos then
		self.unfoldInfos = {}
	end

	local space = 0
	GUILayout.BeginArea(self:GetFullScreenAreaRect())
	GUILayout.BeginVertical()

	GUILayout.BeginHorizontal()
	if GUIFun.Button("Load All", false, space) then
		NewBundleManager.instance:LoadAll()
	end

	if GUIFun.Button("Unload", false, space) then
		NewBundleManager.instance:UnloadAll(false)
	end
	if GUIFun.Button("Unload All", false, space) then
		NewBundleManager.instance:UnloadAll(true)
	end

	if GUIFun.Button("Unload Unused Assets", false, space) then
		ResourceManager.UnloadUnusedAssets();
	end
	GUILayout.EndHorizontal()

	scrollPos = GUILayout.BeginScrollView(scrollPos, false, true, GUILayout.Width(Screen.width));
	GUILayout.BeginVertical()

	GUIFun.Label(tostring(NewBundleManager.instance), false, space)

	GUILayout.EndVertical()
	GUILayout.EndScrollView()

	GUILayout.BeginHorizontal()
	if GUILayout.Button("close", GUIFun.Height(100)) then
		self._funObj:Close()
	end
	GUILayout.EndHorizontal()

	GUILayout.EndVertical()
	GUILayout.EndArea()
end


function P:OnGUI()
	GUIFun.Init()
	GUILayout.Box("", GUILayout.Height(Screen.height), GUILayout.Width(Screen.width))
	self:Show()

	local scrollPosition = self.guiInfo.scrollPos
	local scrollDragSpeed = self.guiInfo.scrollDragSpeed

	ImguiWindowCtrl.ScrollByTouch(scrollPosition, scrollDragSpeed)

	-- if UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.Return) then
	-- 	logError("sfdsf")
	-- 	self:Cmd(cmdText)
	-- end
end